import request from "@/api/request";
import type { AxiosResponse } from "axios";


export type GetGameParams = {
  channel: number | string,
  game_name: string,
  page: number,
  page_size: number
}
export function getGame(params: GetGameParams): Promise<AxiosResponse> {
  return request('minigame/query_game_list', params, 'post')
}

export type CreateGameParams = {
  channel: number | string,
  game_name: string,
  url: string,
  image: File,
  icon: File,
  recommend: string,
  sort_value: number,
  class_id: number
} | FormData
export function createGame(params: CreateGameParams): Promise<AxiosResponse> {
  return request('minigame/create_game_data', params, 'post')
}

export type DeleteGameParams = {
  game_id: number
}
export function deleteGame(params: DeleteGameParams): Promise<AxiosResponse> {
  return request('minigame/delete_game_data', params, 'post')
}

export type GetDetailParams = {
  game_id: number
}
export function getDetail(params: GetDetailParams): Promise<AxiosResponse> {
  return request('minigame/query_game_data', params, 'post')
}

export type UpdateGameParams = {
  game_id: number,
  channel: number,
  recommend: number,
  game_name: string,
  url: string,
  image: string,
  icon: string,
  sort_value: string,
  class_id: number,
} | FormData
export function updateGame(params: UpdateGameParams): Promise<AxiosResponse> { 
  return request('minigame/update_game_data', params, 'post')
}